#include"Processbar.h"
#include<unistd.h>
double bandwidth =1024*1024*1.0;
//download
void download(double filesize,callback_t cb)
{
   // double filesize = 100*1024*1024;//100M
    double current = 0.0;

    printf("download begin, current: %lf\n",current);
    while(current <= filesize)
    {
      cb(filesize,current);
      //从网络中获取数据
      current += bandwidth;
     usleep(50000);

    }
    printf("\ndownload done, filesize: %lf\n",filesize);

}
int main()
{
  //printf("\000[1;31;40mHello World!\000[0m\n");
  
  //ProcBar(100.0,56.9);
  //ProcBar(100.0,1.0);
  //ProcBar(100.0,99.9);
  //ProcBar(100.0,100);
  download(100*1024*1024,ProcBar);
  download(10*1024*1024,ProcBar);
  download(900*1024*1024,ProcBar);
  download(88*1024*1024,ProcBar);
  download(234*1024*1024,ProcBar);

  return 0 ;
}
